package com.ysd.lis.controller;


import com.ysd.common.Result;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.TPermission;
import com.ysd.lis.entity.TPermissionClass;
import com.ysd.lis.service.TPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * cold_chain.t_permission 前端控制器
 * </p>
 *
 * @author Peng
 * @since 2021-10-10
 */
@Api(value = "权限管理")
@RestController
@RequestMapping("/api/sys")
public class TPermissionController extends BaseController {

    @Autowired
    TPermissionService tPermissionService;

    @ApiOperation("查询所有权限列表")
    @GetMapping("/findPermissionClassList")
    public Result findPermissionClassList(){
        return  tPermissionService.findPermissionClassList();
    }

    @ApiOperation("查询所有权限列表")
    @GetMapping("/findPermissionListByClassId")
    public Result findPermissionListByClassId(@RequestParam String classId){
        return  tPermissionService.findPermissionListByClassId(classId);
    }

    @ApiOperation("添加权限分类")
    @PostMapping("addPermissionClass")
    public Result addPermissionClass(@RequestBody TPermissionClass tPermissionClass){
        return tPermissionService.addPermissionClass(tPermissionClass);
    }

    @ApiOperation("修改权限分类")
    @PostMapping("editPermissionClass")
    public Result editPermissionClass(@RequestBody TPermissionClass tPermissionClass){
        return tPermissionService.editPermissionClass(tPermissionClass);
    }

    @ApiOperation("删除权限分类")
    @PostMapping("deletePermissionClass")
    public Result deletePermissionClass(@RequestBody TPermissionClass tPermissionClass){
        tPermissionClass.setDelFlag(1);
        return tPermissionService.deletePermissionClass(tPermissionClass);
    }

    @ApiOperation("添加权限")
    @PostMapping("addPermission")
    public Result addPermission(@RequestBody TPermission tPermission){
        return tPermissionService.addPermission(tPermission);
    }
    @ApiOperation("修改权限")
    @PostMapping("editPermission")
    public Result editPermission(@RequestBody TPermission tPermission){
        return tPermissionService.editPermission(tPermission);
    }

    @ApiOperation("删除权限")
    @PostMapping("deletePermission")
    public Result deletePermission(@RequestBody TPermission tPermission){
        return tPermissionService.deletePermission(tPermission);
    }

}
